# -*- coding: utf-8 -*-

__author__ = 'bilibili'

import xlrd

class spot_excel_reader:
    # FUNCTION: __init__(self, string, string)
    #   the constructor of the class spot_excel_reader
    # ARGS:
    #   @excel_file_name: the excel file name that needs to be read
    #   @sheet_name: the sheet to be read from the excel
    def __init__(self, excel_file_name, sheet_name):
        excel = xlrd.open_workbook(excel_file_name)
        self.sheet = excel.sheet_by_name(sheet_name)

    # FUNCTION: get_cube(self, int, int)
    #   to get the content from excel's cube
    # ARGS:
    #   @row: the row number
    #   @col: the column number
    # RETURN:
    #   string: the content in the given cube
    def get_cube(self, row, col):
        return self.sheet.row_values(row)[col]

    # FUNCTION: get_row(self, int)
    #   to get the whole row specified by given number
    # ARGS:
    #   @row: the row number
    # RETURN:
    #   list: the whole row content
    def get_row(self, row_num):
        return self.sheet.row_values(row_num)

    # FUNCTION: get_row_count(self)
    #   to get number of rows
    # RETURN:
    #   int: the row count
    def get_row_count(self):
        return self.sheet.nrows

def test_spot_excel_reader():
    reader = spot_excel_reader('AM_Report.xls', 'Report 1')
    print reader.get_cube(4, 4)

if __name__ == '__main__':
    test_spot_excel_reader()